import koa from "koa"
const app =new koa();

app.use(async(ctx,next)=>{
    let token = ctx.request.header['X-Auth-Token'];
    if(token && token==='valid-token-123'){
        await next()
    }else {
        ctx.response.body={
            "error": "Unauthorized",
            "message": "Invalid or missing token"
        }
    }
})
app.use(async (ctx,next)=>{
    ctx.body= `有效`
})

app.listen(8000)